import Vue from 'vue'
import App from './App'
import router from './router'
import iView from 'iview';
import 'iview/dist/styles/iview.css';
import axios from 'axios'
let base = '';
base = 'http://172.16.16.147:8080';
console.log(process.env.BASE_URL)
var baseUrl = process.env.BASE_URL ? process.env.BASE_URL:base;
Vue.prototype.axios = axios;
axios.defaults.baseURL = baseUrl;
axios.interceptors.request.use(
  config => {
iView.Message.destroy();
iView.LoadingBar.start();
return config
},err => {
  iView.Message.error('错误的传参');
  return Promise.reject(err);
})
axios.interceptors.response.use(
  response => {
  iView.LoadingBar.finish();
return response
},err => {
  if(err.response){
    iView.Message.error({
      content:err.response.data,
      duration: 0,
      closable: true
    })

  }else{
    iView.Message.error({
      content:'【服务器连接超时，请联系管理员!】',
      duration: 0,
      closable: true
    })
  }
  iView.LoadingBar.error();
  return Promise.reject(err)
}
)
iView.Message.config({
  duration: 3
});

Vue.config.productionTip = false
Vue.use(iView);
// Vue.use(axios);
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  template: '<App/>',
  components: { App }
})
